"HTML.data.frame.min" <- 
function (x, ...)
# minimal (but smaller output) HTML output of a data frame
{
    x <- format(x)
    x <- as.matrix(x)
    x[is.na(x)] <- " "
    x[is.nan(x)] <- " "
    x[grep("^ *(NA|NaN) *$", x)] <- " "
    header <- paste("<table", HTMLargs(list(...)),">")
    rowheader <- paste(paste(c('<tr><th>',rep.int('<th>', ncol(x) - 1)),
                             c(as.matrix(colnames(x))),
                             c(rep.int('</th>', ncol(x) - 1),'</th></tr>'),
                             sep = ""),
                       collapse="")
    body <- paste(paste(c('<tr><td>', rep.int('<td>', ncol(x) - 1)),
                        c(t(x)),
                        c(rep.int('</td>', ncol(x) - 1),'</td></tr>'),
                        sep = ""),
                  collapse="")
    trailer <- "</table>" 
    paste(header, rowheader, body, trailer, sep="")
}
"HTML.individual.row.of.df" <- 
function (x, ...)
# make an HTML table for each row of 'x'
{
    x <- format(x)
    x <- as.matrix(x)
    x[is.na(x)] <- " "
    x[is.nan(x)] <- " "
    x[grep("^ *(NA|NaN) *$", x)] <- " "
    header <- paste('"<table ', HTMLargs(list(...)),">")
    rowheader <- paste(paste(c('<tr><th>',rep.int('<th>', ncol(x) - 1)),
                             c(as.matrix(colnames(x))),
                             c(rep.int('</th>', ncol(x) - 1),'</th></tr>'),
                             sep = ""),
                       collapse="")
    trailer <- '</table>",'
    paste(paste(c(paste(header,rowheader,'<tr><td>'), rep.int('<td>', ncol(x) - 1)),
                c(t(x)),
                c(rep.int('</td>', ncol(x) - 1),paste('</td></tr>',trailer)),
                sep = ""),
          collapse="")
}
runjavascript <- function(filename) 
  # loads a javascript file and runs it
  # must have HTML enabled
  #cat('&amp;nbsp;&lt;SCRIPT TYPE="text/javascript" DEFER src="data.js"&gt;&lt;SCRIPT&gt;')<br>
  # this replaces the above line, which doesn't work under IE.
  # see https://lists.latech.edu/pipermail/javascript/2004-January/006879.html
  cat('&nbsp;<SCRIPT TYPE="text/javascript" DEFER>q="\u0022";(e=document.createElement("script")).src="',
      filename,
      '";e.type="text/javascript"; document.getElementsByTagName("head")[0].appendChild(e);</SCRIPT>',
      sep="")

"jsViaImage" <- function(js)
  # Runs a javascript snippet by attaching it to an error handler for an image.
  # HTML must be enabled.
  # see also: # http://24ways.org/advent/have-your-dom-and-script-it-too
  #   <img src="g.gif?randomnum" alt="" 
  #        onload="alert('Now that I have your attention...');this.parentNode.removeChild(this);" />
  H("img", src = "", alt = "", style = "display:none",
    onerror = paste(js, ";this.parentNode.removeChild(this);"))
"jsViaImage" <- function(js)
  # Runs a javascript snippet by attaching it to an error handler for an image.
  # HTML must be enabled.
  # see also: # http://24ways.org/advent/have-your-dom-and-script-it-too
  #   <img src="g.gif?randomnum" alt="" 
  #        onload="alert('Now that I have your attention...');this.parentNode.removeChild(this);" />
  cat('<img src="" alt="", style="display:none" onerror=',
        js, ";this.parentNode.removeChild(this);/>")
"HTMLjs" <- function(js)
  # Runs a javascript snippet by attaching it to an error handler for an image.
  # HTML must be enabled.
  # see also: # http://24ways.org/advent/have-your-dom-and-script-it-too
  #   <img src="g.gif?randomnum" alt="" 
  #        onload="alert('Now that I have your attention...');this.parentNode.removeChild(this);" />
  H(NULL,"&nbsp;",
    H("script", type="text/javascript", defer="defer",
      js))
